# Maintainer: George Rawlinson <grawlinson@archlinux.org>

pkgname=python-uri-template
pkgver=1.2.0
pkgrel=2
pkgdesc='An implementation of RFC 6570 URI Templates'
arch=('any')
url='https://github.com/plinss/uri_template'
license=('MIT')
depends=('python')
makedepends=(
  'git'
  'python-build'
  'python-installer'
  'python-wheel'
  'python-setuptools'
)
_commit='ae070b1716c853fbc5a3c879e6ef1d1cfb2c9533'
source=("$pkgname::git+$url#commit=$_commit")
b2sums=('SKIP')

pkgver() {
  cd "$pkgname"

  git describe --tags | sed 's/^v//'
}

prepare() {
  cd "$pkgname"

  # below string is extracted from upstream's setup.py
  # version='0.0.0',  # version will get replaced by git version tag - do not edit
  sed -e "s:\(version='\)0.0.0:\1$pkgver:" -i setup.py
}

build() {
  cd "$pkgname"

  python -m build --wheel --no-isolation
}

check() {
  cd "$pkgname"

  python test.py
}

package() {
  cd "$pkgname"

  python -m installer --destdir="$pkgdir" dist/*.whl

  # documentation
  install -vDm644 -t "$pkgdir/usr/share/doc/$pkgname" README.md

  # license
  install -vDm644 -t "$pkgdir/usr/share/licenses/$pkgname" LICENSE
}
